﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Forum.Entity.Member;
using Frame.Lib.Core.Base;
using Frame.Lib.Web;

namespace Forum.DAL.Member
{
    public class ForumMemberDAL : BaseDAL
    {       
        public List<ForumMemberInfo> GetList(PagerSortSetting pagerSetting, string condition, object[] conditionParas)
        {
            string sql = "select count(*) from ForumMember as a inner join MemberBase as b on a.ID = b.ID where " + condition;
            pagerSetting.RecordCount = dbOper.Query<int>(sql, conditionParas).First();

            sql = "select * from (select (row_number() over (order by " + pagerSetting.SortExpression + " " + pagerSetting.SortDirection + ")) as RowID,a.*,b.Name, b.LoginName, b.Password, b.Mobile, b.Email from " +
                        "ForumMember as a inner join MemberBase as b on a.ID = b.ID where " + condition + ") as c where RowID between " + (pagerSetting.SkipCount + 1) + " and " + (pagerSetting.SkipCount + pagerSetting.PageSize);
            List<ForumMemberInfo> list = dbOper.Query<ForumMemberInfo>(sql, conditionParas);

            return list;
        }


    }
}
